package com.github.elliot.gatewaycenter.util;

import cn.hutool.crypto.digest.DigestUtil;

import javax.crypto.SecretKey;
import java.time.Instant;
import java.util.UUID;

public class HeadUtil {

    public static void main(String[] args) throws Exception {

        /*String requestBody = "{\n" +
                "    \"id\":1,\n" +
                "    \"customerNo\":\"123\"\n" +
                "}";

        String base64Key = "XYyOyWILUQ9IYXbeTv8u/3t7nGXCAfyzD2/ESrEtR5o=";
        SecretKey secretKey = AESEncryptionUtil.loadKey(base64Key);

        String requestBody2 = AESEncryptionUtil.encrypt(requestBody, secretKey);

        System.out.println(requestBody2);*/

        String requestBody = "/user-center/test/testOne";

        String token = "Bearer eyJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJhbGwiLCJhdWQiOiJhMTdiYWI5Y2M4OTk0MThhYjE4YzYzZjMxZDE0NTM3ZSIsInVzZXJObyI6ImExN2JhYjljYzg5OTQxOGFiMThjNjNmMzFkMTQ1MzdlIiwicm9sZXMiOltdLCJpc3MiOiJ3eXNpd3lnLmNvbSIsImV4cCI6IjE3NjU1NzU0MTkiLCJpYXQiOiIxNzYyOTgzNDE5IiwidXNlcm5hbWUiOiJFbGxpb3QifQ.HuAz0_SPGRNkXRiK4MnsGaMZZ7Oioik-xDKerJkVQgL02RlV8pud3pHRunAHQvaQXUHZkboVNa4w6n9aMyvdH2h6hKA5CkGpDgtGGE5UkP7fypaSm0F8SYcKoxHpWwDSNKUrY7tcZY_QegJP9u20E169Y4O8GPceDesmsBUrMUsbU0qUY9x3zqhu5VrlFTYzx0mQ16s2-0WIEVQqOXWsIQL6ZOARfoM78hMfo7dBSaneD1ihfWJr4JNh-2ySI1D5laWiZg26lGOa47clUEa2__QpsY69SCQJdLp4g8zWeusqh_lE-a4ajz1JXIGaG8-Vk99fCnK5k1PQFu0EYzB1Bg";

        long epochMilli = Instant.now().toEpochMilli();
        System.out.println("epochMilli:" + epochMilli);
        String uuidStr = UUID.randomUUID().toString().replaceAll("-", "");
        System.out.println("uuidStr:" + uuidStr);
        String data = token + "1762954658819" + "1dcb0c8ca0aa4238b314d953b7719298" + requestBody;
        String sign = DigestUtil.sha256Hex(data);
        System.out.println("sign:" + sign);
    }
}
